<?php
// This file is used to return different resources via AJAX calls to be consumed by artifact_control.php functions.
// TODO - check user permissions
// TODO - once Elgg provides an easy way to load session information w/o the entire lib,
//          remove the large includes.php file, as none of the rest depends on libs outside
//          of mysql support & generic php.


// Headers are needed to force IE to not cache results.
header('Cache-Control: no-cache, no-store, must-revalidate'); //HTTP/1.1
header('Expires: Sun, 01 Jul 2005 00:00:00 GMT');
header('Pragma: no-cache'); //HTTP/1.0

require_once('../../../includes.php');

    require_once("../view/resource.php");
    require_once("../model/artifact.php");
    require_once("../model/page.php");
    require_once("../model/decoration.php");

// Load a list of artifacts in resource view.

// Current user for which we should show their artifacts.
$userid = $_SESSION['userid']; //intval( $_GET['userid'] );


// Artifacts being loaded.
$type = $_GET['type'];

// Owner of the current page.
$page_owner = intval( $_GET['page_owner'] );
$page_ident = intval( $_GET['page_ident'] );

// -1 stands for the wildcard, aka -- any of this type.
$key = folio_resource::encodeKey( -1, $type, $userid );

// Retrieve a list of resources.
$resources = folio_resource::SelectWhereKey( $key );
$html = folio_ResourceTree::ResourceList( $resources, $page_owner, $page_ident ) ;

echo $html;

?>
